import javax.sound.sampled.*;

public class AudioUtil {
    public static TargetDataLine getTargetDataLine() throws LineUnavailableException {
        AudioFormat format = new AudioFormat(8000.0f, 16, 1, true, false);
        DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
        TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info);
        line.open(format);
        return line;
    }

    public static SourceDataLine getSourceDataLine() throws LineUnavailableException {
        AudioFormat format = new AudioFormat(8000.0f, 16, 1, true, false);
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
        SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
        line.open(format);
        return line;
    }
}
